home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sources
/
xrsh
/
xrsh_57.gz
/
xrsh_57
Wrap
Text File
|
1994-06-06
|
45KB
|
1,260 lines
#---------------------------------- cut here ----------------------------------
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by James J Dempsey <jjd@spchp17> on Mon Jun 6 13:14:51 1994
#
# This archive contains:
# xrsh.sh xrlogin.sh xrsh.man xrlogin.man
# COPYRIGHT ChangeLog FUTURE-WORK Imakefile
# README
#
# Existing files will not be overwritten.
# Error checking via wc(1) will be performed.
LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH
if test -f xrsh.sh
then
echo Ok to overwrite existing file xrsh.sh\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f xrsh.sh
if test -f xrsh.sh
then
echo Error: could not remove xrsh.sh, aborting
exit 1
fi
fi
echo x - xrsh.sh
cat >xrsh.sh <<'@EOF'
#!/bin/sh
# Some System V systems don't understand the #! construct.
# If your system does understand it, put ": " at the beginning of the line.
#
XRSH_VER='xrsh version 5.7'
XRSH_RCS='$Header: /nfs/spserv/u5/jjd/xrsh/RCS/xrsh.sh,v 1.9 1994/06/06 17:11:26 jjd Exp $'
XRSH_TIME='Time-stamp: <94/06/06 13:11:12 jjd>'
#
# Copyright 1991 by James J. Dempsey <jjd@bbn.com>
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, James J. Dempsey makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
#
# xrsh: start an X11 client on another host
#
# Usage: xrsh [-help] [-version ] [-l username] [-auth authtype] [-screen #] [-pass envlist] \
# [-debug] [-debug2] hostname [X-command [arguments...]]
#
# Example usage: xrsh expo.lcs.mit.edu xterm
#
# Runs the given command on another host with $DISPLAY set in the environment.
# Handles authentication using xhost, xauth, or $XAUTHORITY (or none).
# Xrsh is very careful not to leave any extra processes waiting
# around on either machine for the client to exit. In order
# to achieve this, csh is used on the remote host and all inputs
# and outputs are redirected to /dev/null.
# The -debug switch allows you to see errors, but doesn't worry about
# leaving extra processes around.
# The -debug2 switch sets -x so that you can see every command
# executed by the script (very verbose)
# The -l switch allows you to use a different login name on the
# remote host. -l and its argument are passed directly to rsh.
# The -help switch prints out the usage message.
# The -screen switch allows you to start a client on a different screen.
# If no X command is given, it defaults to xterm. This means that
# 'xrsh remotehost' will start an xterm on remotehost.
# If the given command is a path that ends in "xterm", it adds the
# arguments "-name xterm-$hostname" where $hostname is the name
# of the remote host. This allows you to customize your server's
# xrdb database to set attributes, such as the window color, based
# on the name of remote host. If you dislike this behaviour, specify
# your own -name argument to xterm on the xrsh command line.
#
# Xrsh handles authentication based on the value of $XRSH_AUTH_TYPE or
# the value of the -auth command line switch. The value can
# be xhost, xauth, environment or none. It defaults to xhost.
# xhost -- run xhost to enable the remote host to open window
# run xhost on the host where the server is running
# xhost-xterminal --
# run xhost to enable the remote host to open windows
# run xhost on the host where xrsh was first run
# xauth -- merge the auth entry from this host on the remote
# host using xauth via rsh
# environment -- pass the $XAUTHORITY environment variable from the
# local host to the remote host so that a common
# NFS accessable authority file can be used everywhere
# none -- do nothing. Assume the user has handled authentication.
#
# If the environment variable XRSH_RSH_ERRORS is set to the name of a file,
# any rsh errors will appear in that file on the remote host.
# If that variable is unset, error messages will be thrown away unless
# the -debug switch is given. (Note: don't use ~ in the filename
# because it will expand to ~ on the local host, but try to put the
# errors in that file on the remote host.)
#
#
# COMMON PROBLEMS:
# * Make sure your PATH environment variable on the remote host is
# set in your .cshrc or .bashrc so that rsh programs have
# access to it. (/bin/sh and /bin/ksh users have a hard time
# time here since their shells don't execute any init files
# under rsh. One way to do this is to use the XRSH_ENVS_TO_PASS
# environment variable to pass PATH to the remote shell.
# Optionally, you can type a full path to xrsh.
# E.g. xrsh remote-host /usr/bin/X11/xterm
#
# * Make sure your PATH environment variable on the remote host
# includes the directory containing the X programs. This is
# often /usr/bin/X11 or /usr/local/bin/X11.
# * Make sure you have rsh configured to work on the remote host.
# You can test this by typing: rsh remote-host echo '$PATH'
# This will prove that rsh works and show you the PATH that
# will be used on the remote host. If you get "Permission
# denied." you probably need to update your ~/.rhosts file
# on the remote host. See rlogin(1).
#
# Until X11R5, this command used to be called "xon". The name was
# changed in order to be more descriptive, to have a name that better
# matches its cousin (xrlogin) and to not collide with a similar command
# written by Keith Packard distributed with X11R5.
#
# Written by Jim Dempsey <jjd@bbn.com> with help from Stephen Gildea
# <gildea@bbn.com> based on an idea by Dave Mankins <dm@think.com>.
# Some additional features due to dgreen@cs.ucla.edu,
# "David B. Rosen" <rosen@park.bu.edu>, Eero Simoncelli
# <eero@whitechapel.media.mit.edu> and Martin Friedmann
# <martin@whitechapel.media.mit.edu>
# Originally written around 1987.
# Last modification by jjd@bbn.com.
# Version 5.1 of xrsh was distributed with X11R5.
# initialize some variables
default_auth_type=xhost # sites might want to change this
authenv=
foundarg=
progname=`basename $0`
rshoptions=""
passenvs= # environment variables to pass along
xhostvar= # used by auth type xhost-xterminal
usage="usage: $progname [-help] [-version] [-l username] [-auth authtype] [-screen #] [-debug] [-debug2] host [cmd [args ...]]"
if [ -z "$DISPLAY" ]; then
echo "$progname: "'$DISPLAY must be set' 1>&2 ;
exit 1
fi
if [ -z "$XRSH_RSH_ERRORS" ]; then
XRSH_RSH_ERRORS=/dev/null
fi
# process command line arguments
until [ "$foundarg" = "no" ]
do
foundarg=no
case $1 in
-version)
echo "Version: ${XRSH_VER}"
echo "RCS info: ${XRSH_RCS}"
echo "Last saved: ${XRSH_TIME}"
exit 0
;;
-debug)
debug=t; foundarg=yes; shift;
;;
-debug2)
set -x; foundarg=yes; shift;
;;
-help)
echo $usage; exit 0;
;;
-l)
shift; rshoptions="-l $1"; foundarg=yes; shift;
;;
-auth)
shift; XRSH_AUTH_TYPE=$1; foundarg=yes; shift;
;;
-pass)
shift; XRSH_ENVS_TO_PASS=$1; foundarg=yes; shift;
;;
-screen)
shift;
# this line was blatantly stolen from Keith Packard's xon
DISPLAY=`echo $DISPLAY|sed 's/:\\([0-9][0-9]*\\)\\.[0-9]/:\1/'`.$1
foundarg=yes;
shift;
;;
esac
done
if [ "$#" = "0" ]; then
echo $usage 1>&2; exit 1;
fi
clienthost="$1"; shift # The full remote host name (as full as possible)
command=$1
if [ -z "$command" ]; then # default command to xterm if none specified
command=xterm
else
shift
fi
# Grab the arguments to the command here so that we don't have to worry
# about restoring them when doing IFS hacking below
xcmdargs="$@"
# Try to avoid running hostname.
# Some shells set $HOST or $HOSTNAME automatically.
localhost=${HOST-${HOSTNAME-`hostname`}} # The local host name
# Remove domain part from hostname.
# The following paragraph of IFS based code replaces sed and
# runs faster because it doesn't fork.
# clientshort is remote host name without domain
#clientshort=`echo $clienthost | sed -e 's/\..*$//'`
oldIFS=$IFS
IFS=.
set $clienthost
clientshort=$1
IFS=$oldIFS
# Find display host
# The following paragraph of IFS based code replaces sed and
# runs faster because it doesn't fork.
#displayhost=`echo $DISPLAY | sed 's/:.*//'`
oldIFS=$IFS
IFS=:
set $DISPLAY
case "$#" in
1) displayhost=$localhost;;
*) displayhost=$1;;
esac
IFS=$oldIFS
case "$displayhost" in
"unix"|"local"|"")
displayhost=$localhost;;
esac
# People use the -name resource to specify host-specific resources
# such as window color.
if [ `basename "$command"` = "xterm" ]; then
command="$command -name xterm-$clientshort -title 'xterm@$clientshort'"
fi
if [ $# -ge 1 ]; then
command="$command $xcmdargs"
fi
# Some System V hosts have rsh as "restricted shell" and ucb rsh is remsh
if [ -r /usr/bin/remsh ]; then
rsh=remsh
elif [ -f /usr/bin/rcmd ]; then # SCO Unix uses "rcmd" instead of rsh
rsh=rcmd
else
rsh=rsh
fi
# Construct the new $DISPLAY for the remote client
# The following paragraph of IFS based code replaces sed and
# runs faster because it doesn't fork. It also handles the arp stuff.
# newdisplay="`echo $DISPLAY | sed \"s/^[^:]*:/${localhost}:/\"`"
oldIFS=$IFS
IFS=:
set $DISPLAY
if [ $# = 2 ]; then
shift
fi
case "$clienthost" in
# If the remote host is the localhost, then don't put the hostname
# in $DISPLAY and let X find the fastest display path
"$displayhost")
newdisplay=:$@
;;
# if a full internet domain name is used, set $DISPLAY
# using IP address so remote host will be guaranteed return path
*.*)
if [ -f /usr/etc/arp ]; then
arp=/usr/etc/arp
elif [ -f /etc/arp ] ; then
arp=/etc/arp
else
arp=arp
fi
address=`$arp $displayhost |tr ')' '(' | awk -F'(' '{print $2}'`
if [ "$address" ]; then
newdisplay="$address:$@"
else
newdisplay="${displayhost}:$@"
fi
;;
# A host in the local domain
*)
newdisplay="${displayhost}:$@"
;;
esac
IFS=$oldIFS
# process env variables to pass early so that we can send them
# in the xauth commands as well as the actual X client rsh command.
# This is necessary for brain-dead shells like ksh which don't run
# any init files to set the path properly. The user can instead
# send PATH as an XRSH_ENVS_TO_PASS.
for variable in $XRSH_ENVS_TO_PASS
do
if eval [ \""\${$variable-Xyzzy}"\" != "Xyzzy" ]; then
eval passenvs="\"setenv $variable '\$$variable'; $passenvs"\"
fi
done
# Use $XRSH_AUTH_TYPE to determine whether to run xhost, xauth,
# propagate $XAUTHORITY to the remote host, or do nothing
case ${XRSH_AUTH_TYPE-$default_auth_type} in
xhost)
if [ "$newdisplay" != "$DISPLAY" ]; then
# If run on the same host as server, allow remote host access X server.
if [ "$debug" ]; then
xhost +$clienthost
else
xhost +$clienthost > /dev/null 2>&1
fi
else
# If run on a different host as the server, use rsh to allow
# access to the host in DISPLAY.
xhostcmd="setenv DISPLAY $DISPLAY; exec xhost +$clienthost"
if [ "$debug" ]; then
# send $passenvs in case the user has a brain dead remote shell
# and needs to be able to pass the PATH env var (e.g. ksh)
echo "Executing \"xhost +$clienthost\" on $displayhost with DISPLAY=$DISPLAY"
$rsh "$displayhost" exec /bin/csh -cf "\"$passenvs $xhostcmd\"" < /dev/null
else
$rsh "$displayhost" exec /bin/csh -cf "\"$passenvs $xhostcmd < /dev/null >& /dev/null\"" < /dev/null > /dev/null 2>&1
fi
fi
;;
xhost-xterminal)
# If run on an X terminal, rsh to the XDMCP host to run xhost
# if this is the first time, we are on the XDMCP host and
# we can just run xhost.
if [ "$XHOST" = "" ]; then
xhostvar="setenv XHOST $localhost; "
if [ "$debug" ]; then
xhost +$clienthost
else
xhost +$clienthost > /dev/null 2>&1
fi
else
xhostvar="setenv XHOST $XHOST; "
xhostcmd="setenv DISPLAY $DISPLAY; exec xhost +$clienthost"
# send $passenvs in case the user has a brain dead remote shell
# and needs to be able to pass the PATH env var (e.g. ksh)
if [ "$debug" ]; then
echo "Executing \"xhost +$clienthost\" on $XHOST with DISPLAY=$DISPLAY"
$rsh "$XHOST" exec /bin/csh -cf "\"$passenvs $xhostcmd\"" < /dev/null
else
$rsh "$XHOST" exec /bin/csh -cf "\"$passenvs $xhostcmd < /dev/null >& /dev/null\"" > /dev/null < /dev/null 2>&1
fi
fi
;;
xauth)
# the "xauth remove" is theoretically unnecessary below,
# but due to a bug in the initial X11R5 (fixed in fix-09) xauth,
# entries for MIT-MAGIC-COOKIE-1 get lost if
# you do merge twice without the remove. The remove
# command can be removed when xauth gets fixed.
if [ "$debug" ]; then
xauth extract - $newdisplay | \
$rsh $clienthost $rshoptions exec /bin/csh -cf "\"$passenvs xauth remove $newdisplay ; xauth merge -\""
else
# Conditionalize this on $passenvs so that we don't pay the price
# of forking a csh on the remote host if we don't need environment
# variables evaluated.
if [ "$passenvs" ]; then
xauth extract - $newdisplay | \
$rsh $clienthost $rshoptions exec /bin/csh -cf "\"$passenvs xauth remove $newdisplay ; xauth merge -\"" >/dev/null 2>&1 < /dev/null
else
xauth extract - $newdisplay | \
$rsh $clienthost $rshoptions xauth remove $newdisplay \;xauth merge - >/dev/null 2>&1 < /dev/null
fi
fi
;;
none)
;;
environment)
authenv="setenv XAUTHORITY $XAUTHORITY; "
;;
*)
echo -n "$progname: "'$XRSH_AUTH_TYPE must be set to "xhost", ' 1>&2
echo '"xhost-xterminal", "xauth", "environment" or left unset' 1>&2
exit 1
;;
esac
# Do the real work using rsh.
# Don't use -n to rsh because SG IRIX doesn't support it.
# Use < /dev/null instead.
if [ "$debug" ]; then
echo "Executing \"$command\" on $clienthost with DISPLAY=$newdisplay"
$rsh $clienthost $rshoptions /bin/csh -cf "\"setenv DISPLAY $newdisplay; $authenv $xhostvar $passenvs $command\"" < /dev/null
else
#
# The redirection inside the innermost quotes is done by csh. The outer
# redirection is done by whatever shell the user uses on the remote end.
# The inner redirection is necessary for an error log -- the outer
# redirection is necessary to make sure that the local rsh doesn't hang around.
#
# The outermost < /dev/null is to simulate the -n argument to rsh which
# we don't want to use for portability reasons.
#
# The three sets of redirections are for the local shell, the login shell
# on the remote host and the csh on the remote host.
#
# We would like the last '>' to be '>&' or equivalent, but that would make this
# code dependent on what flavor of shell the user uses on the remote host
#
exec $rsh $clienthost $rshoptions exec /bin/csh -cf "\"setenv DISPLAY $newdisplay; $authenv $xhostvar $passenvs exec $command < /dev/null >>& $XRSH_RSH_ERRORS \" < /dev/null > /dev/null " < /dev/null
fi
@EOF
set `wc -lwc <xrsh.sh`
if test $1$2$3 != 406229915679
then
echo ERROR: wc results of xrsh.sh are $* should be 406 2299 15679
fi
chmod 555 xrsh.sh
if test -f xrlogin.sh
then
echo Ok to overwrite existing file xrlogin.sh\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f xrlogin.sh
if test -f xrlogin.sh
then
echo Error: could not remove xrlogin.sh, aborting
exit 1
fi
fi
echo x - xrlogin.sh
cat >xrlogin.sh <<'@EOF'
#!/bin/sh
# Some System V systems don't understand the #! construct.
# In this case replace the first line with just a colon (:)
#
# Copyright 1991 by James J. Dempsey <jjd@bbn.com>
# Version 5.3
# Time-stamp: <92/09/14 09:58:49 jjd>
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, James J. Dempsey makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Starts a local xterm running rlogin or telnet
# Written by Stephen Gildea <gildea@expo.lcs.mit.edu>
# and Jim Dempsey <jjd@bbn.com>
#
# Usage: xrlogin [-l username] [-telnet] [emulator options] hostname
# Set some defaults.
progname=`basename $0`
usage="usage: $progname [-l logname] [-telnet] [emulator options] host"
netprog="rlogin"
netprogopts="-8"
termprog=xterm
termprogopts=
telnet=
user=
host=
# process arguments
while [ "$*" != "" ]; do
case "$1" in
-telnet)
telnet=t;
;;
-l)
if [ "$telnet" ]; then
echo "$progname: Can't use -l with -telnet" 1>&2
echo $usage 1>&2
exit 1
fi
user=$2; shift;
;;
*)
# assume anything else is an argument to terminal emulator
# (except the last one which is the hostname)
termprogopts="$termprogopts $1"
;;
esac
shift
done
if [ "$user" -a "$telnet" ]; then
echo "$progname: Can't use -l with -telnet" 1>&2
echo $usage 1>&2
exit 1
fi
if [ "$telnet" ]; then
netprog=telnet;
netprogopts= ;
fi
if [ "$user" ]; then
netprogopts="$netprogopts -l $user"
fi
# last item in termprogopts is the hostname by definition
# (arg list and man page)
item=
# xyzzy keeps shell from getting confused if option begins with '-'
set xyzzy $termprogopts
termprogopts=
shift
for i in $@
do
if [ ! -z "${item}" ]; then
termprogopts="$termprogopts $item"
fi
item=$i
done
host=$item
if [ "$XRLOGIN_TERM_EMULATOR" != "" ]; then
termprog=$XRLOGIN_TERM_EMULATOR
else
case "$TERM" in
*term)
# TERM looks like it is an X11 terminal emulator, so use it.
# Should also look for *terminalEmulatorName resource.
termprog=$TERM;;
esac
fi
if [ "$termprog" = "xterm" ]; then
termprogopts="$termprogopts -ut"
fi
# Remove domain part from hostname.
name=`echo $host | sed -e 's/\..*$//'`
# netprogopts are required to go after hostname on some SYS V hosts
exec $termprog -name $termprog-$name -title $name $termprogopts -e $netprog $host $netprogopts
@EOF
set `wc -lwc <xrlogin.sh`
if test $1$2$3 != 1064092827
then
echo ERROR: wc results of xrlogin.sh are $* should be 106 409 2827
fi
chmod 555 xrlogin.sh
if test -f xrsh.man
then
echo Ok to overwrite existing file xrsh.man\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f xrsh.man
if test -f xrsh.man
then
echo Error: could not remove xrsh.man, aborting
exit 1
fi
fi
echo x - xrsh.man
cat >xrsh.man <<'@EOF'
.\" Copyright 1991,1994 by James J. Dempsey <jjd@bbn.com>
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
.\" documentation for any purpose is hereby granted without fee, provided that
.\" the above copyright notice appear in all copies and that both that
.\" copyright notice and this permission notice appear in supporting
.\" documentation, James J. Dempsey makes no representations about the
.\" suitability of this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.TH XRSH 1 "Release 6" "X Version 11"
.SH NAME
xrsh \- start an X program on a remote machine
.SH SYNOPSIS
.B xrsh
[
.B \-help
] [
.B \-version
] [
.B \-l
.I username
] [
.B \-auth
.I authtype
] [
.B \-screen
.I screen-#
] [
.B \-pass
.I envlist
] [
.B \-debug
] [
.B \-debug2
]
.I remote-host
[
.I X-command
[
.I arguments ... ] ]
.SH DESCRIPTION
.I Xrsh
runs the given X command on a remote host. It sets up the environment for
that command such that it will display its windows on the current
server's screen by propagating the $DISPLAY environment variable.
If not specified, the default client is \fIxterm\fP. Xrsh automatically
selects \fIrsh\fP(1), \fIremsh\fP(1) or \fIrcmd\fP(1) to execute remote commands, depending
on what is available the O/S environment.
.PP
Xrsh automatically handles authentication so that the remote client
will be allowed to open windows on the server. It does this in
several different ways depending on the value of the $XRSH_AUTH_TYPE
environment variable or the \-auth argument.
.PP
By default, xrsh will use xhost to enable the remote client to open a
server connection. It can also be told to use xauth to merge local
keys into a remote authorization file. Or it can pass the $XAUTHORITY
environment variable to the remote host in order to share a common NFS
mounted authority file. It can also be directed to do nothing in the
case where no explicit authorization is necessary.
.PP
Users who just want a remote terminal window might look at xrsh's
sister command, xrlogin(1). Xrlogin uses a locally running xterm to
open an rlogin connection to a remote host. The decision on whether
to use "xrsh host xterm" or "xrlogin host" should be based on several
factors. If X is unavailable on the remote host or the local terminal
emulator has better features, use xrlogin. In general, the author
recommends using xrsh over xrlogin in most situations.
.PP
If the command to execute on the remote host is an xterm, xrsh
automatically passes the -name argument to xterm with a value of
"xterm-hostname" where hostname is the name of the remote host. This
allows the user to specify resources in their server's resource
manager which are specific to xterms from a given host. For example,
this feature can be used to make all xterm windows from a given remote
host be the same color or use a specific font or start up in a
specific place on the screen. Xrlogin passes the same string so they
are compatible in this regard. This feature can be overridden by
specifying your own -name argument on the xterm command line.
.PP
If the command to execute on the remote host is an xterm, xrsh specifies
that the default title for the new xterm will be "xterm@hostname"
where hostname is the name of the remote host. This can also be
overridden by specifying your own -title argument on the xterm command
line.
.PP
Xrsh is very careful not to leave any extra processes
on either the local or remote machine waiting around for the client to
exit. In some remote environments (particularly some Sys V
implementations of csh and rsh), this is impossible and xrsh should be
run as a background command.
.SH OPTIONS
Note that xrsh options precede the given X command and its arguments.
.sp
.IP "\fB\-auth authtype\fP"
Choose what type of X authorization (or access control) is going to be
used. Authtype can be one of "xhost", "xauth", "xhost-xterminal", "environment", or
"none". The default is xhost, but the default can be set by setting
the value of the environment variable $XRSH_AUTH_TYPE.
.IP
If xhost is specified and the X server is running on the local
machine, xhost will be run locally to enable the remote host to open an X
connection. If the server is on a third host (not the one where xrsh
is running and not the one where you wish to run the command), rsh will
be used to run xhost on the server host to authorize the host where
the command will be run.
.IP
If xauth is specified, then xrsh will merge the entries for the server from
the local $XAUTHORITY file into that of the remote host using rsh.
.IP
The authtype xhost-xterminal is intended for use by people using X terminals.
If xhost-xterminal is used, then the first time xrsh is run, it runs xhost locally to
enable the remote host for access. This should work since (theoretically)
the first time it is run is on the XDMCP host for the X terminal. From then
on it propagates the name of that host to all remote hosts via the environment
variable $XHOST. In subsequent invocations from remote hosts, xrsh uses rsh
to connect to the host $XHOST and run xhost to enable new remote hosts.
.IP
Authtype "none" does no explicit work for access control. Use this if you
don't enable access control or if you use another mechanism for access
control.
.IP
Finally, authtype "environment" automatically propagates the environment
variable $XAUTHORITY to remote hosts, assuming that it is an NFS
mounted location that can be accessed from all hosts.
.IP "\fB-debug\fP"
Normally xrsh redirects standard input and standard output to
/dev/null in an effort to cause unneeded rshd and shell processes to
exit. As a result, the user can't usually see any errors that might
occur (like a "Permission denied." from rsh). If you are having
trouble getting xrsh to work with a remote host, try giving the -debug
switch to see if any errors are being generated.
.IP "\fB-debug2\fP"
This switch causes xrsh to turn on the -x option in the shell so that
the user can see every shell command executed by xrsh. Only use this
script if you are debugging the xrsh code itself.
.IP "\fB-help\fP"
Print out the argument list to standard output.
.IP "\fB-l username\fP"
Use the -l switch to specify a different user name to use for logging
in via rsh on the remote host.
.IP "\fB-pass envlist\fP"
Envlist is a quote delimited string naming an arbitrary set of
environment variables to pass on to the shell environment on the
remote host. If one wanted to set $XRSH_AUTH_TYPE and $XAUTHORITY to
the remote host, one could use: -pass "XRSH_AUTH_TYPE XAUTHORITY".
A default set of environment variables to pass may be set using the
environment variable $XRSH_ENVS_TO_PASS.
.IP "\fB-screen screen-#\fP"
Specify a different screen on the server on which to display the
remote client.
.IP "\fB-version\fP"
Print out version information and exit.
.SH ENVIRONMENT
The environment variables XRSH_AUTH_TYPE and XRSH_ENVS_TO_PASS which
can be used to set switch defaults are overridden if the equivalent
switch is specified as well.
.IP "\fBXAUTHORITY\fP"
The $XAUTHORITY environment variable is passed to the remote host if
the authtype specified by -auth or $XRSH_AUTH_TYPE is "environment".
.IP "\fBXRSH_AUTH_TYPE\fP"
This environment variable can be used to specify the default type of
authorization or access control. The values it can be set to are the
same as the values for the argument -auth.
.IP "\fBXRSH_RSH_ERRORS\fP"
If the environment variable XRSH_RSH_ERRORS is set to the name of a file,
any rsh errors will appear in that file on the remote host.
If that variable is unset, error messages will be thrown away unless
the -debug switch is given. (Note: don't use ~ in the filename
because it will expand to ~ on the local host, but try to put the
errors in that file on the remote host.)
.IP "\fBXRSH_ENVS_TO_PASS\fP"
.SH COMMON PROBLEMS
Make sure your PATH environment variable on the remote host is
set in your .cshrc or .bashrc so that rsh programs have
access to it. (/bin/sh and /bin/ksh users have a hard time
time here since their shells don't execute any init files
under rsh. You can use the XRSH_ENVS_TO_PASS environment variable
to pass the PATH environment variable to the remote host. Optionally,
you can type a full path to xrsh in that case.
(E.g. xrsh remote-host /usr/bin/X11/xterm))
.PP
Make sure your PATH environment variable on the remote host
includes the directory containing the X programs. This is
often /usr/bin/X11 or /usr/local/bin/X11.
.PP
Make sure you have rsh configured to work on the remote host.
You can test this by typing: rsh remote-host echo '$PATH'
This will prove that rsh works and show you the PATH that
will be used on the remote host. If you get "Permission
denied." you probably need to update your ~/.rhosts file
on the remote host. See rlogin(1).
.SH EXAMPLES
.IP "xrsh yoda"
Start an xterm on the host yoda which displays on the current X
server. Use xhost for access control.
.IP "xrsh -auth xauth underdog emacs"
Start an emacs on the host underdog. Merge xauth authorization
entries for this server into the authority file on the remote host.
.IP "xrsh -l mjd -auth none -pass XRSH_AUTH_TYPE -debug tigger xterm -fn 5x7"
Start an xterm on the host tigger in a very small font, propagate the
environment variable $XRSH_AUTH_TYPE to the remote host, login to the
remote host using the id "mjd", don't do any specific authorization
and don't redirect standard/error output to /dev/null so I can see any errors.
.SH BUGS
.PP
If the values of the environment variables specified in -pass or
$XRSH_ENVS_TO_PASS contain quote characters, xrsh will have difficulty.
.PP
If the remote host can't resolve the hostname of the server host
(through /etc/hosts, DNS or NIS), the remote client will not be able
to open a connection to the server.
.PP
System V users may need to make the first line of the script begin
with colon (:).
.SH SEE ALSO
.PP
xrlogin(1), rsh(1), xhost(1), xauth(1)
.SH AUTHOR
James J. Dempsey <jjd@bbn.com> with help and suggestions from many
people including gildea@expo.lcs.mit.edu, dm@think.com,
dgreen@cs.ucla.edu and rosen@cns.bu.edu, <eero@whitechapel.media.mit.edu>,
and <martin@whitechapel.media.mit.edu>.
@EOF
set `wc -lwc <xrsh.man`
if test $1$2$3 != 223172510259
then
echo ERROR: wc results of xrsh.man are $* should be 223 1725 10259
fi
chmod 444 xrsh.man
if test -f xrlogin.man
then
echo Ok to overwrite existing file xrlogin.man\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f xrlogin.man
if test -f xrlogin.man
then
echo Error: could not remove xrlogin.man, aborting
exit 1
fi
fi
echo x - xrlogin.man
cat >xrlogin.man <<'@EOF'
.\" Copyright 1991,1994 by James J. Dempsey <jjd@bbn.com>
.\"
.\" Permission to use, copy, modify, distribute, and sell this software and its
.\" documentation for any purpose is hereby granted without fee, provided that
.\" the above copyright notice appear in all copies and that both that
.\" copyright notice and this permission notice appear in supporting
.\" documentation, James J. Dempsey makes no representations about the
.\" suitability of this software for any purpose. It is provided "as is"
.\" without express or implied warranty.
.TH XRLOGIN 1 "Release 6" "X Version 11"
.SH NAME
xrlogin \- start an xterm that uses rlogin or telnet to connect to a remote host
.SH SYNOPSIS
.B xrlogin
[-l username] [-telnet] [xterm options] remote-host
.SH DESCRIPTION
.I Xrlogin
opens an xterm window and runs rlogin or telnet to login to a remote host.
.PP
Xrlogin
automatically passes the -name argument to xterm with a value of
"xterm-hostname" where hostname is the name of the remote host. This
allows the user to specify resources in their server's resource
manager which are specific to xterms from a given host. For example,
this feature can be used to make all xterm windows to a given remote
host be the same color or use a specific font or start up in a
specific place on the screen. Xrsh(1) passes the same string so they
are compatible in this regard.
.PP
Xrlogin specifies that the default title for the new xterm will be
"hostname" where hostname is the name of the remote host. This and
the -name argument above can be overridden with xterm-options on the
command line.
.PP
One could also use xrlogin's sister command xrsh(1) to open a window
to a remote host. In the case of xrsh, the xterm would run on the
remote host and use X as the connection protocol while xrlogin would
run the xterm on the local host and use rlogin or telnet as the
connection protocol. See xrsh(1) for a discussion of the merits of
each scheme.
.SH OPTIONS
.IP "\fB-l username\fP"
When not using -telnet, use username as the id to login to the remote
host.
.IP "\fB-telnet\fP"
Use the -telnet protocol to open the connection instead of rlogin. In
general rlogin is preferred because it can be configured to not prompt
the user for a password. Rlogin also automatically propagates window
size change signals (SIGWINCH) to the remote host so that applications
running there will learn of a new window size. Use of telnet
provided mostly for hosts that don't support rlogin.
.SH COMMON PROBLEMS
Make sure that the local host is specified in the .rhosts file on the
remote host or in the remote hosts /etc/hosts.equiv file. See
rlogin(1) for more information.
.SH EXAMPLES
.IP "xrlogin -bg red yoda"
Start a local red xterm which connects to the remote host yoda using rlogin.
.IP "xrlogin -telnet c70"
Open a local xterm which connects to the remote host c70 using telnet.
.SH SEE ALSO
.PP
xrsh(1), rlogin(1), telnet(1)
.SH AUTHOR
James J. Dempsey <jjd@bbn.com> and Stephen Gildea <gildea@expo.lcs.mit.edu>.
@EOF
set `wc -lwc <xrlogin.man`
if test $1$2$3 != 655113013
then
echo ERROR: wc results of xrlogin.man are $* should be 65 511 3013
fi
chmod 444 xrlogin.man
if test -f COPYRIGHT
then
echo Ok to overwrite existing file COPYRIGHT\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f COPYRIGHT
if test -f COPYRIGHT
then
echo Error: could not remove COPYRIGHT, aborting
exit 1
fi
fi
echo x - COPYRIGHT
cat >COPYRIGHT <<'@EOF'
# Copyright 1991,1994 by James J. Dempsey <jjd@bbn.com>
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, James J. Dempsey makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
@EOF
set `wc -lwc <COPYRIGHT`
if test $1$2$3 != 986530
then
echo ERROR: wc results of COPYRIGHT are $* should be 9 86 530
fi
chmod 444 COPYRIGHT
if test -f ChangeLog
then
echo Ok to overwrite existing file ChangeLog\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f ChangeLog
if test -f ChangeLog
then
echo Error: could not remove ChangeLog, aborting
exit 1
fi
fi
echo x - ChangeLog
cat >ChangeLog <<'@EOF'
Mon Jun 6 11:10:23 1994 James J Dempsey (jjd@spchp17.BBN.COM)
* Added some /dev/null redirections to rsh commands to fix hanging
problem when using csh as login shell and xrsh'ing to some remote
OSes like HP-UX. Upped version to 5.7.
* Changed Imakefile comments from # to XCOMM as per gildea@x.org.
* Added double quotes around assignment of xcmdargs at gildea's
suggestion.
Fri Jun 3 11:10:23 1994 James J Dempsey (jjd@spchp17.BBN.COM)
* Released version 5.6 to X Consortium for X11R6 contrib after
making only minor cosmetic changes from the version called 5.6
below. Most (all?) of the changes were in the supporting README
type files and man pages.
Fri Mar 18 17:22:46 1994 James J Dempsey (jjd@spchp17)
* Added -version feature at the request of rws@x.org
Now at version 5.6.
Mon Sep 14 09:57:27 1992 James J Dempsey (jjd at spchp17)
* Fixed a bug in xrlogin reported by dave@csis.dit.csiro.au.
The problem was that if xterm options were sent in on the xrlogin
cmd line, $item wasn't set and generates a "test: arg expected"
error. Replaced with [ ! -z ""]. Updated version to 5.3.
Fri Jun 5 10:06:39 1992 James J Dempsey (jjd@spchp17)
* Fixed line in xrsh.man which caused groff to barf due to
quoting. Reported by Paul Eggert <eggert@twinsun.com>
Thu Apr 16 15:32:39 1992 James J Dempsey (jjd@spchp17)
* Changed the xrsh man page to remove the restriction that ultrix
should run with /bin/sh5. Now that I use "set -" instead of "set
--" it works with the old Ultrix /bin/sh again.
Mon Mar 9 15:28:09 1992 James J Dempsey (jjd@spchp17)
* made some changes to xrsh and xrlogin due to suggestions
by Charles Karney <karney@theory.pppl.gov>.
Changed xrlogin to take arbitrary xterm options. Made those
options be after "-name -title" so users can override.
Fixed a bug where client host was checking to see if it was the
same as localhost in order to set display to :0, when it should
have been checking to see if it was the same as displayhost.
Added default_auth_type so sites can customize the default
authorization to be something other than xhost.
New xrsh version 5.3.
New xrlogin version 5.2.
@EOF
set `wc -lwc <ChangeLog`
if test $1$2$3 != 583582185
then
echo ERROR: wc results of ChangeLog are $* should be 58 358 2185
fi
chmod 444 ChangeLog
if test -f FUTURE-WORK
then
echo Ok to overwrite existing file FUTURE-WORK\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f FUTURE-WORK
if test -f FUTURE-WORK
then
echo Error: could not remove FUTURE-WORK, aborting
exit 1
fi
fi
echo x - FUTURE-WORK
cat >FUTURE-WORK <<'@EOF'
Here are some unstated goals for the xrsh script to consider in
designing enhancements:
1. Keep xrsh as one script. Configuration and installation are more
difficult with ancillary files. As one script, it can be copied
easily from system to system.
2. Keep xrsh portable. Avoid features which might not work on all
UNIX variants. E.g. some rsh don't have a -n option. Some
/bin/sh don't have shell functions.
3. Keep the number of programs fork()ed by xrsh to a minimum. xrsh is
used a lot and always interactively so speed is important. This is
why I play all those games with IFS, to avoid forking awk or sed.
Here are some things which might be done in the future or have been
recently tried.
1. Parse the DISPLAY environment variable without forking any extra
processes like sed. Perhaps use IFS in the shell.
<done, but doesn't work in Ultrix /bin/sh>
2. Pass other environment variables besides $DISPLAY. Users might
want to pass an arbitrary set.
<can now pass XAUTHORITY using XRSH_AUTH_TYPE and arbitrary
environment variables using XRSH_ENVS_TO_PASS>
3. Don't use backslashes for quoting, only use only ' and " for portability.
<What hosts don't handle backslashes? This turns out to be very hard.>
4. Pass $XUSERFILESEARCHPATH to the remote host?
<I'm not sure this is always what you want to do, but you can
do it if you want to using XRSH_ENVS_TO_PASS.>
5. Add command line flag to describe the remote machine (like -sysv or
-irix). This would get all the config options correct without having
to guess.
<I hope not to have to do this -- I hope to make the one script portable.>
6. If you have to rsh the xhost to the serverhost, run it in the
background and use wait before the final rsh to improve speed.
<I did this, but it made some system V hosts (HP-UX 7.0) go insane and
say "wait: pid 232 is not a child of this shell" over and over again.
I finally deleted it in the interests of portability. Timing showed
it wasn't a major win in speed anyway>
7. Expand DISPLAY environment variable from foo to foo.org.com so
that it works when you leave your local site.
<hard to do in a site independent manner. Now uses ip addresses if the
remote host name contains periods like foo.bar.com>
8. Decide rsh vs. remsh vs. rcmd at install time instead of run time.
<disadvantage: one script can't be transferred from one machine to another>
9. make first line be : instead of #!
<Can't -- without #! some systems use $SHELL to eval scripts. May not
be the right thing>
10. Use IP address when setting $DISPLAY for remote hosts that can't
resolve local hostname.
<This is done for remote host names with . in them>
11. Have an .xrsh.rc file which can be used to tailor defaults for
specific hosts.
12. If using xhsot authorization, optionally disable access to the
host after running the command. Of course, on hosts where rshd
doesn't return, the xhost -host would never get executed until the
client exitied. This feature was requested by Rick Calder, NCR
Systems Support Center - New Jersey [att!]rick!rick rick@rick.att.com
attmail!rcalder.
13. (From kmp@harlequin via gildea@expo.lcs.mit.edu) in order to preserver
users quoting for arguments to client, don't preparse $@ into a variable
and then pass that variable along to the client via rsh.
Instead, of setting and resetting the cmd line args for IFS hacking, push
a marker on the arg list and push other things on the front. Then
shift things off the front and stop when you get to the marker.
at the end, just pass $@ along as the arguments to the client.
set new stuff XYZZY "$@"
@EOF
set `wc -lwc <FUTURE-WORK`
if test $1$2$3 != 856243606
then
echo ERROR: wc results of FUTURE-WORK are $* should be 85 624 3606
fi
chmod 444 FUTURE-WORK
if test -f Imakefile
then
echo Ok to overwrite existing file Imakefile\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f Imakefile
if test -f Imakefile
then
echo Error: could not remove Imakefile, aborting
exit 1
fi
fi
echo x - Imakefile
cat >Imakefile <<'@EOF'
XCOMM Copyright 1991 by James J. Dempsey <jjd@bbn.com>
XCOMM
XCOMM Permission to use, copy, modify, distribute, and sell this software and
XCOMM its documentation for any purpose is hereby granted without fee,
XCOMM provided that the above copyright notice appear in all copies and that
XCOMM both that copyright notice and this permission notice appear in
XCOMM supporting documentation, James J. Dempsey makes no representations
XCOMM about the suitability of this software for any purpose. It is provided
XCOMM "as is" without express or implied warranty.
PROGRAMS = xrsh xrlogin
all:: $(PROGRAMS)
InstallNamedProg(xrsh.sh,xrsh,$(BINDIR))
InstallManPage(xrsh,$(MANDIR))
InstallNamedProg(xrlogin.sh,xrlogin,$(BINDIR))
InstallManPage(xrlogin,$(MANDIR))
depend::
@EOF
set `wc -lwc <Imakefile`
if test $1$2$3 != 2097775
then
echo ERROR: wc results of Imakefile are $* should be 20 97 775
fi
chmod 444 Imakefile
if test -f README
then
echo Ok to overwrite existing file README\?
read answer
case "$answer" in
[yY]*) echo Proceeding;;
*) echo Aborting; exit 1;;
esac
rm -f README
if test -f README
then
echo Error: could not remove README, aborting
exit 1
fi
fi
echo x - README
cat >README <<'@EOF'
This distribution contains two programs, xrsh and xrlogin.
Both are shell scripts.
Xrsh is designed to allow you to start an X client on a remote machine
with the window displayed on the current server's $DISPLAY. It has
many options that give you the ability to propagate environment
variables (including DISPLAY) to the remote system and works with
various types of X server access control including xauth and xhost.
In X11R4 and previous, xrsh was called "xon". There was a script in
X11R5 by Keith Packard by that name which has no relation to the
originally distributed xon script.
Xrlogin opens a local xterm window and runs rlogin or telnet to
connect to a remote machine.
Starting with the X11R5 version, xrsh has many new features
including a multitude of X access control methods, the ability to pass
arbitrary environment variables to the remote host and the ability to
start a client on a different screen than the current one.
To install on your system, the usual thing is to do an "xmkmf"
followed by a "make install".
IMPORTANT:
If you are running a System V variant, you may need to change the
first line of both scripts from "#!/bin/sh" to ": ".
James J. Dempsey
jjd@bbn.com
4 October 1991
Updated for X11R6: 3 June 1994
@EOF
set `wc -lwc <README`
if test $1$2$3 != 342161250
then
echo ERROR: wc results of README are $* should be 34 216 1250
fi
chmod 444 README
exit 0